import random
import re
from urllib.request import urlopen

from bs4 import BeautifulSoup

base_url = "https://8lhx.com"
url = base_url
html = urlopen(url).read().decode('utf-8')
soup = BeautifulSoup(html, features='lxml')
sum=1
all_href = soup.find_all("article",{"class":"excerpt"})
for iii in all_href:
    ii=iii.find('h2')
    i=ii.find("a",{"href":re.compile('https://8lhx.*?')})
    print(sum,i.get_text())
    print(i['href'],'\n')
    sum=sum+1

for his in range(2,21):
    urll = "/page/"
    url = base_url+urll+str(his)
    html = urlopen(url).read().decode('utf-8')
    soup = BeautifulSoup(html, features='lxml')

    all_href = soup.find_all("article",{"class":"excerpt"})
    for iii in all_href:
        ii=iii.find('h2')
        i=ii.find("a",{"href":re.compile('https://8lhx.*?')})
        print(sum,i.get_text())
        print(i['href'],'\n')
        sum=sum+1